<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>admin</title>

    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="/static/css/admin/bootstrap.min14ed.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/font-awesome.min93e3.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/iCheck/custom.css">
	<link rel="stylesheet" type="text/css" href="/static/css/admin/animate.min.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/style.min862f.css"/>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form id="auth_form"  method="post"  class="form-horizontal" onsubmit="return false;">
                            
                            <div class="form-group">
                                <label class="col-sm-1 control-label text-navy">角色名：</label>
                                <div class="col-sm-5">
                                    <input type="text" name="role_name" value="{$roleInfo.role_name|default=''}" id="role_name" placeholder="输入角色名" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label text-navy">描述：</label>
                                <div class="col-sm-5">
                                    <textarea name="role_describe" value="" id="role_describe" class="form-control" placeholder="输入角色描述"  style="margin:0px; height: 93px; max-width:100%;">{$roleInfo.role_describe|default=''}</textarea>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>

                            <volist name="menu" id="parent">
                                <div class="form-group">
                                    <label class="col-sm-1 control-label checkbox-inline-block i-checks text-navy">
                                        <input type="checkbox" name="role_auth[]" value="{$parent['controller']}" <if condition="in_array($parent['controller'],$action)">checked</if>>{$parent['name']}
                                    </label>
                                    <volist name="parent.child" id="child">
                                        <div class="col-sm-2">
                                            <div class="checkbox i-checks">
                                                <label class="checkbox-inline-block i-checks text-navy">
                                                    <input type="checkbox" value="{$child['action']}" name="role_auth[]" <if condition="in_array($child['action'],$action)">checked</if>><i></i>{$child['name']}
                                                </label>
                                            </div>
                                            <volist name="child.auth" id="auth">
                                                <div class="checkbox i-checks">
                                                    <label>
                                                        <input type="checkbox" value="{$auth['action']}" name="role_auth[]" <if condition="in_array($auth['action'],$action)">checked</if>><i></i>{$auth['name']}
                                                    </label>
                                                </div>
                                            </volist>
                                        </div>
                                    </volist>
                                </div>
                                <div class="hr-line-dashed"></div>
                            </volist>

                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <input type="hidden" id="role_id" name="role_id" value="{$roleInfo.role_id|default=''}" />
                                    <input type="hidden" id="handle_type"  name="handle_type"  value="{$type}" />
                                    <button class="btn btn-primary" type="submit" onclick="roleAuthSubmit();">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <js href="/static/js/admin/jquery.min.js"/>
	<js href="/static/js/admin/bootstrap.min.js"/>
	<js href="/static/js/admin/content.min.js"/>
    <js href="/static/js/admin/plugins/iCheck/icheck.min.js"/>
    <js href="/static/js/admin/plugins/layui/layer/layer.js"/>
     <!-- <js href="/static/js/admin/admincommon.js"/> -->
    <script type="text/javascript" src="/static/js/admin/admincommon.js?v=20180712"></script>

    <script>
        $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green"})});
        
        
        function roleAuthSubmit(){
            var data = $("#auth_form").serializeArray();
            if($("#role_name").val()=='') {
                
                layer.msg('请填写角色名', {time:500, icon:5});
                 
                return false;
            }
            
            var handle_type = $("#handle_type").val();

            if(handle_type == 'add') 
                url = "{:url('admin/Role/addRoleAuth')}";

            else if(handle_type == 'update')

                url = "{:url('admin/Role/updateRoleAuth')}";

            $.post(url,data,function(data){
            
                if(data.code == 1) {
                    
                    layer.msg(data.msg, {time:500, icon:6});
                 
                    return false;
                    
                }else {

                    layer.msg(data.msg, {time:500, icon:5});
                 
                    return false;
                }

            },'json');
        }
    </script>
</body>
</html>